package com.shenmazong.serverwebpoem.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
import com.shenmazong.serverwebpoem.mapper.ITbAdminMapper;
import com.shenmazong.serverwebpoem.pojo.TbAdmin;
import com.shenmazong.serverwebpoem.service.TbAdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.annotation.Target;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 田不平
 * @project server-web-poem
 * @date 2020/3/23 4:23 PM
 * http://www.shenmazong.com
 */

@Slf4j
@Service
public class TbAdminServiceImpl implements TbAdminService {

    @Autowired
    ITbAdminMapper iTbAdminMapper;

    @Override
    public void add(TbAdmin admin) {
        iTbAdminMapper.insert(admin);
    }

    @Override
    public void del(Integer id) {
        iTbAdminMapper.deleteById(id);
    }

    @Override
    public void set(TbAdmin admin) {
        iTbAdminMapper.updateById(admin);
    }

    @Override
    public TbAdmin getById(Integer id) {
        return iTbAdminMapper.selectById(id);
    }

    @Override
    public TbAdmin getByName(String name) {

        return iTbAdminMapper.selectOne(new QueryWrapper<TbAdmin>().eq("username", name));
    }
}
